<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .item {
            display: flex;
            width: 400px;
            height: 50px;
            background-color: red;
            text-align: center;
            line-height: 50px;
        }
        
        .item>div {
            flex: 1;
        }
        
        .green {
            background-color: green;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- <div class="item">
            <div :class="[type=='a'?'green':'']" @click="fn1('a')">商品</div>
            <div :class="[type=='b'?'green':'']" @click="fn1('b')">评价</div>
            <div :class="[type=='c'?'green':'']" @click="fn1('c')">规格</div>
            <div :class="[type=='d'?'green':'']" @click="fn1('d')">售后</div>
        </div> -->
        <div class="item">
            <div :class="{'green':type=='a'}" @click="fn1('a')">商品</div>
            <div :class="{'green':type=='b'}" @click="fn1('b')">评价</div>
            <div :class="{'green':type=='c'}" @click="fn1('c')">规格</div>
            <div :class="{'green':type=='d'}" @click="fn1('d')">售后</div>
        </div>
        <div>
            <div v-if="type=='a'">商品的内容</div>
            <div v-else-if="type=='b'">评价的内容</div>
            <div v-else-if="type=='c'">规格的内容</div>
            <div v-else>售后的内容</div>
        </div>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        data: {
            type: 'a'
        },
        methods: {
            fn1(val) {
                this.type = val
                console.log('-------------val:' + val);
            }
        }
    })
</script>

</html>